package dataMode;

import java.io.UnsupportedEncodingException;

public class QR8Bit extends QRData {

	public QR8Bit(String data, int version, int errorCorrectionLevel) {
		super(data, version, errorCorrectionLevel);
		super.mode =  QRData.MODE_BINARY;
		
		super.encodeDataToBinary();
	}

	protected void encode() {
		StringBuffer buffBinaryData = new StringBuffer();

		byte[] decimalData = null;
		
		try {
			// Transformation des caractères de la chaine saisie en valeurs JIS8
			decimalData = super.data.getBytes("SJIS");
		}
		catch(UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		
		// Transformation des valeurs JIS8 en binaire
		for(byte b : decimalData)
			buffBinaryData.append(super.addZeroOnLeft(Integer.toBinaryString(b), 8));
		
		super.binaryData += buffBinaryData.toString();
	}
}